<template>
  <iframe class="import-i-frame" v-if="url" :src="url" frameborder="0"></iframe>
</template>
<script>
import {buildUrlParams} from '@/utils'
import {getUserInfo} from '@/utils/auth'

export default {
  name: 'anyReport',
  data() {
    return {
      token: '',
      params: {
        id: this.$route.params.id
      },
      url: ''
    }
  },
  created() {
    this.getUrl()
  },
  methods: {
    getUrl() {
      this.$ajax.get('/ms-forms/anyReport/getUrlById', {reportId: this.params.id}).then(response => {
        const success = response.success
        if (success) {
          const data = response.data
          this.url = buildUrlParams(data.url, {userId: getUserInfo('id')})
        }
      })
    }
  }
}
</script>
